<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools"></t:base>
<script type="text/javascript" src="${webRoot}/plug-in/fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="${webRoot}/plug-in/fancybox/fancybox/jquery.fancybox-1.3.4.js"></script>
<link rel="stylesheet" type="text/css" href="${webRoot}/plug-in/fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
    <t:datagrid name="userAlbums" title="" actionUrl="officialWhController.do?miniSpecialDatagrid" fit="true" idField="specialId" queryMode="group" onLoadSuccess="loadSuccess">
      <t:dgCol title="id" field="specialId" hidden="true"></t:dgCol>
      <t:dgCol title="专题名称"   field="name" query="true"></t:dgCol>
      <t:dgCol title="编辑"   field="audit.realName" query="true"></t:dgCol>
      <t:dgCol title="专题主图"   extendParams="formatter:LogoFormatter;" field="pic"  ></t:dgCol>
      <t:dgCol title="专题说明"  field="remark"></t:dgCol>
      <t:dgCol title="专题推广位置" field="spreadPosition" dictionary="ablumSpreadPosition"  query="true" ></t:dgCol>
      <t:dgCol title="专题推广时间"  formatter="yyyy-MM-dd hh:mm:ss" field="spreadTime"></t:dgCol>
      <t:dgCol title="点击量"   field="clickRate"></t:dgCol>
      <t:dgCol title="创建时间"  formatter="yyyy-MM-dd hh:mm:ss" field="createTime"></t:dgCol>
      <%--<t:dgCol title="是否删除" field="deleted" dictionary="isno"></t:dgCol>--%>

      <%--<t:dgCol title="common.operation" field="opt" ></t:dgCol>--%>
      <%--<t:dgFunOpt operationCode="selectSpecial" title="专题文章" funname="f_optArticle(specialId)" ></t:dgFunOpt>--%>
      <%--<t:dgDelOpt operationCode="deleteSpecial"  url="specialController.do?delSpecial&specialId={specialId}" title="删除"></t:dgDelOpt>--%>

      <%--<t:dgToolBar operationCode="addSpecial"  title="新增" langArg="common.user" icon="icon-add" url="specialController.do?addorupdate" width="800"  funname="add"></t:dgToolBar>--%>
      <%--<t:dgToolBar operationCode="editSpecial" title="修改" langArg="common.user" icon="icon-edit" url="specialController.do?addorupdate" width="800"  funname="f_updateAlbum"></t:dgToolBar>--%>
    </t:datagrid>


<div style="display: none">
  <t:formvalid formid="formobj" layout="div" dialog="true" action="specialController.do?saveSpecialArticle" beforeSubmit="setArticleIds">
    <input id="specialId" name="specialId" type="hidden">
    <input id="articleId" name="articleIds"  type="hidden" value="${articleId}">
  </t:formvalid>
</div>
<script>
  function setArticleIds() {
    $("#specialId").val(getUserListSelections('specialId'));
    return true;
  }

  function getUserListSelections(field) {
    var ids = [];
    var rows = $('#userAlbums').datagrid('getSelections');
    for (var i = 0; i < rows.length; i++) {
      ids.push(rows[i][field]);
    }
    ids.join(',');
    return ids
  }
</script>


<script type="text/javascript">

  $(function() {
    var li_east = 0;
  });

  /**
   * 重写 更新事件打开窗口
   * @param title 编辑框标题
   * @param addurl//目标页面地址
   * @param id//主键字段
   */
  function f_updateAlbum(title,url, id,width,height) {
    gridname=id;
    var rowsData = $('#'+id).datagrid('getSelections');
    if (!rowsData || rowsData.length==0) {
      tip('请选择编辑项目');
      return;
    }
    if (rowsData.length>1) {
      tip('请选择一条记录再编辑');
      return;
    }

    url += '&specialId='+rowsData[0].specialId;
    createwindow(title,url,width,height);
  }

  function articleImg(){
    $("a[rel=datagrid_group]").fancybox({
      'overlayShow'	: false,
      'transitionIn'	: 'elastic',
      'transitionOut'	: 'elastic'
    });
  }

  function LogoFormatter(val,row){
    if(val != null && val != "" && val != undefined){
      val += "?" + new Date().getTime();
    }
    return '<a rel="datagrid_group" href="'+val+'" title=""><img alt="" src="'+val+'"  style="width:30px;height:30px;"></a>';
  }

  function loadSuccess() {

    articleImg();

  }

  function f_optArticle(specialId){

    var rowsData = $('#userAlbums').datagrid('getSelections');
    setTimeout(function(){

      var title = rowsData[0].name + '的所属文章';
      if(li_east == 0){
        $('#main_typegroup_list').layout('expand','east');
      }
      $('#main_typegroup_list').layout('panel','east').panel('setTitle', title);
      $('#userListpanel').panel("refresh", "specialController.do?specialArticleList&specialId=" + specialId);

    },10);

  }

</script>
